home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ8801.ZIP
/
NARO.ZIP
/
NARO.EXP
< prev
next >
Wrap
Text File
|
1980-01-01
|
5KB
|
158 lines
/* This program demonstrates the use of the LOCATE utility. It
contains all of the components of a typical C program to exercise
the startup code and locate utility.
*/
char *ptr = "class DATA" ; /* Initialized data */
int array[10][10] ; /* Uninitialized data */
main()
{
int i, j ; /* Automatics */
static char *s = "" ; /* Static initialized data */
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
array[i][j] = i * j ;
}
strcpy(s, ptr) ; /* Bring in a library function */}
Example 1: The demonstration program
C>masm /MX tc, tc, tc ;
Microsoft (R) Macro Assembler Version 4.00
Copyright (C) Microsoft Corp 1981, 1983, 1984, 1985. All rights reserved.
49272 Bytes symbol space free
0 Warning Errors
0 Severe Errors
C>tcc -c -ml demo
Turbo C Version 1.0 Copyright (c) 1987 Borland International
demo.c:
Available memory 293342
Example 2: Compiling the C source code and the MASM start-up module
C>type demo.map
Start Stop Length Name Class
00000H 00035H 00036H _TEXT CODE
00036H 0007FH 0004AH DEMO_TEXT CODE
00080H 000A8H 00029H STRCPY_TEXT CODE
000B0H 000BFH 00010H _ETEXT CODEEND
000C0H 000D3H 00014H _DATA DATA
000E0H 001A7H 000C8H _BSS BSS
001A8H 001A8H 00000H _BSSEND BSSEND
001B0H 003AFH 00200H _STACK STACK
Address Publics by Value
0000:0000 START
0003:0006 _MAIN
0008:0000 _STRCPY
000B:0010 TEND
000C:0000 _PTR
000C:0000 IDATA
000C:0020 ARRAY
000C:0020 BDATA
000C:00E8 EDATA
001B:0200 TOS
Program entry point at 0000:0000
Example 3: The linker map file
;
; This configuration file is used with Turbo C to build a ROMable
; image. It defines physical addresses for three classes, makes a
; copy of the initialized data class to keep in ROM and instructs
; the locator the order of the different classes.
;
dup DATA CONST ; Make a copy of the initialized data class
; and name it CONST
class CODE = 0xfc00 ; Start code at address FC000H
class STACK = 0x0080 ; The stack at address 00800H
class DATA = 0x0100 ; DGROUP at address 01000H
order DATA BSS BSSEND ; Define the order of DGROUP
order CODE CODEEND CONST ; And the order of classes in ROM
rom CODE CONST ; ROM only the program code and the copy
; of the initialized data that the startup
; code copies from ROM to DGROUP
Example 4: The configuration file
C>type demo.loc
MS-DOS Locate Utility Version 1.0
Input File: DEMO.EXE
Output File: DEMO.HEX
Configuration File: DEMO.CFG
Invoked by: C:\BIN\LOCATE.EXE -b demo
Date/Time: Mon Aug 03 14:40:17 1987
Segment Information
Name Class Address Length_
TEXT CODE FC000H 0036H
DEMO_TEXT CODE FC036H 004AH
STRCPY_TEX CODE FC080H 0029H
_ETEXT CODEEND FC0B0H 0010H
_DATA DATA 01000H 0014H
_BSS BSS 01020H 00C8H
_BSSEND BSSEND 010E8H 0000H
_STACK STACK 00800H 0200H
_DATA NEWDATA FC0C0H 0014H
??BOOT (ABSOLUTE) FFFF0H 0005H
Public Symbols
FC00:0000 START FC03:0006 _MAIN
FC08:0000 _STRCPY FC0B:0010 TEND
0100:00E8 EDATA 0100:0020 BDATA
0100:0020 _ARRAY 0100:0000 IDATA
0100:0000 _PTR 0080:0200 TOS
Entry Point - FC00:0000
Example 5: The ouput from the locator
:02000002FC0000
:10000000FAB880008ED0BC0002B800018EC0B80BD8
:10001000FC408ED8BE00008BFEB920002BCFF3A48D
:10002000061F32C0BF2000B9E8002BCFF3AAFB9A0D
:06003000060003FCEBCA10
:02000002FC03FD
:10000600565733F6EB2433FFEB1A8BC6F7E7508BC4
:10001600C6BA1400F7E28BD88BC7D1E003D858894B
:100026008720004783FF0A7CE14683FE0A7CD7FFD0
:10003600360200FF360000FF360600FF3604009A3F
:0A004600000008FC83C4085F5ECBD5
:02000002FC08F8
:100000005657558BECFC1EC47E0E8BF732C0B9FFE1
:10001000FFF2AEF7D18CC38EDBC47E0AF3A41F8B34
:09002000560C8B460A5D5F5ECBB5
:02000002FC0CF4
:100000000800000113000001436C61737320444138
:040010005441000057
:02000002FFFFFE
:05000000EA000000FC15
:04000003FC000000FD
:00000001FF
Example 6: